package com.sky.controller.admin;

import com.sky.result.Result;
import com.sky.service.WorkspaceService;
import com.sky.vo.BusinessDataVO;
import com.sky.vo.OrderOverViewVO;
import com.sky.vo.SetmealOverViewVO;
import com.sky.websocket.WebSocketServer;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;

@RestController
@RequestMapping("/admin/workspace")
@Api(tags = "工作台接口")
public class WorkspaceController {
    @Autowired
    private WorkspaceService workspaceService;


    @GetMapping("/businessData")
    @ApiOperation("查询营业数据")
    public Result<BusinessDataVO> getbusinessData(){
        LocalDate to = LocalDate.now();
        LocalDateTime begin = LocalDateTime.of(to, LocalTime.MIN);
        LocalDateTime end = LocalDateTime.of(to, LocalTime.MAX);
        BusinessDataVO businessDataVO = workspaceService.getBusinessData(begin,end);
        return Result.success(businessDataVO);
    }

    @GetMapping("/overviewSetmeals")
    @ApiOperation("查询套餐数据")
    public Result<SetmealOverViewVO> overviewSetmeals(){
        SetmealOverViewVO setmealOverViewVO = workspaceService.overviewSetmeals();
        return Result.success(setmealOverViewVO);
    }

    @GetMapping("/overviewDishes")
    @ApiOperation("查询菜品数据")
    public Result<SetmealOverViewVO> overviewDishes(){
        SetmealOverViewVO setmealOverViewVO = workspaceService.overviewDishes();
        return Result.success(setmealOverViewVO);
    }

    @GetMapping("/overviewOrders")
    @ApiOperation("查询订单数据")
    public Result<OrderOverViewVO> overviewOrders(){
        OrderOverViewVO orderOverViewVO = workspaceService.overviewOrders();
        return Result.success(orderOverViewVO);

    }

}
